import http from "@/utils/http";
import config from "@/views/order/InforEntryPPM/config.js";
import pageOfferDetail from "../utils/pageOfferDetail";
export default {
	data() {
		return {
			// 获取PPM配置的接口传参
			ppmParams: {
				productId: this.$route.params.prodId,
				serviceOfferId: this.$route.params.serviceOfferId || "4010100000",
				modType: this.$route.params.modType || "50200003",
				optionId: this.$route.params.optionId || "28",
			},
			formData: {},
			pageData: [],
			ppmParams: {},
		};
	},
	created() {
		
		let ppmParams = JSON.parse(sessionStorage.getItem("ppmCondition"));
		this.ppmParams = ppmParams;
		// 进入页面开始加载PPM配置
		this.loadPPMConfig(this.ppmParams);

	},
	methods: {
		/**
		 * 加载PPM配置 80008002 80008007 80020160
		 */
		async loadPPMConfig(ppmParams) {
			let temp = {
				//this.$route.params.prodId
				productId: "80008007",
				serviceOfferId: "4010100000",
				modType: "50030003",
				optionId: "311"
			}
			let res = await this.qryPageTempAttr(temp);
			// 
			// let res = { code: 200 };
			if (res.code == 200) {
				this.pageData = res.meta.resList.pageModel;
				this.formData = res.meta.resList.paramModel;
				this.setPageOfferDetail(ppmParams);
							
				// setTimeout(() => {
				// 	this.pageData = config.pageModel;
				// 	this.formData = config.paramModel;
				// }, 1000);
			}
		},
		async setPageOfferDetail(params) {
			let temp = {
				//this.$route.params.prodId
				custId: "2045",
				orderSource: "ORDER",
				custSoNumber: "JT202100010014",
				orderItemIds: "38393"
			}



			let res = await this.qryPageOfferDetail(temp)
			// 
			// let res = { code: 200 };
			if (res.resultCode == "0") {

				pageOfferDetail.RewObject(res, this.formData, "80008007");

			}
		},

		/**
		 * 获取PPM配置数据接口
		 * "productId": "80007009","serviceOfferId": "4040100098","modType": "50200002","optionId": "310"
		 * 新装时的后三个参数是这样的,其它业务会有变化
		 * @param {}
		 * @returns
		 */
		async qryPageTempAttr(condition) {
			let res = await http({
				url: `${process.env.VUE_APP_CTX_PPM_QUERY}/ppm-query-server/qryPageTempAttr`,
				data: condition,
				method: "POST",
			});
			return res;
		},
		/**
		 * 查询明细数据
		 * @param {*} condition 
		 * @returns 
		 */
		async qryPageOfferDetail(condition) {
			let res = await http({
				url: `${process.env.VUE_APP_CTX_ORDER_QUERY}/qryCustomerOrderDetailConvertUnderLine`,
				data: condition,
				method: "POST",
			});
			return res;
		}
	},
};
